package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 文章关枚举
 */
public class ArticleConstant {

    /**
     * 文章型（0图文，1视频）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ArticleType implements IntegerEnum<Integer> {

        IMAGE_TEXT(0, "图文"),//图文

        VIDEO(1, "视频"),//视频
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ArticleType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ArticleConstant.ArticleType getByCode(int code) {
            for (ArticleConstant.ArticleType value : ArticleConstant.ArticleType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 类型
     * 0 opus 作品，
     * 1 article 文章，
     * 2 goods其它
     * 3 service 服务
     * 4 other其它
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ModelType implements IntegerEnum<Integer> {

        OPUS(0, "作品"),

        ARTICLE(1, "文章"),

        GOODS(2, "商品"),

        SERVICE(3, "服务"),

        OTHER(4, "其它"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ModelType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ModelType getByCode(int code) {
            for (ModelType value : ModelType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }



}
